<?php echo $this->Html->script('jquery.ui.datepicker-pt-BR');?>

<?php echo $this->Form->create('Emprestimo');?>
<?php echo $this->Form->input('id');?>

<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
    <h4>Renovar Empréstimo</h4>
  </div>
  <div class="modal-body">
			<fieldset>
				<div class="row-fluid">
				<div class="span5">
					<div class="control-group">
						<?php echo $this->Form->Label('Aluno.nome', 'Aluno', array('class' => 'control-label'));	?>
						<div class="controls">
							<?php echo $this->Form->input('Aluno.nome', array('label' => false, 'div' => false, 'disabled', 'class' => 'span12'));	?>
						</div>
					</div>
				</div>
				<div class="span5">
					<div class="control-group">
						<?php echo $this->Form->Label('Projeto.nome', 'Projeto', array('class' => 'control-label'));	?>
						<div class="controls">
							<?php echo $this->Form->input('Projeto.nome', array('label' => false, 'div' => false, 'disabled', 'class' => 'span12'));	?>
						</div>
					</div>
				</div>
				</div>
				<div class="row-fluid">
				<div class="span10">
					<div class="control-group">
						<?php echo $this->Form->Label('Autorizador.nome', 'Professor que autorizou', array('class' => 'control-label'));	?>
						<div class="controls">
							<?php echo $this->Form->input('Autorizador.nome', array('label' => false, 'div' => false, 'disabled', 'class' => 'span12'));	?>
						</div>
					</div>
				</div>
				</div>
				<div class="row-fluid">
				<div class="span5">
					<div class="control-group">
						<?php echo $this->Form->Label('data_inicio', 'Data de início', array('class' => 'control-label'));	?>
						<div class="controls">
							<?php echo $this->element('datepicker', array('field' => 'data_inicio', 'label' => false, 'disabled', 'class' => 'span12')) ?>
						</div>
					</div>
				</div>
				<div class="span5">
					<div class="control-group">
						<?php echo $this->Form->Label('data_entrega', 'Data de entrega', array('class' => 'control-label'));	?>
						<div class="controls">
							<?php echo $this->element('datepicker', array('field' => 'data_entrega', 'label' => false, 'disabled', 'class' => 'span12')) ?>
						</div>
					</div>
				</div>
				</div>
				<div class="row-fluid">
				<div class="span6">
					<div class="control-group">
						<?php echo $this->Form->Label('nova_data_entrega', 'Nova Data de Entrega', array('class' => 'control-label'));	?>
						<div class="controls">
							<?php 
							echo $this->Form->hidden('nova_data_entrega');
							echo $this->Form->input('nova_data_entrega_calendar', array('type' => 'text', 'label' => false, 'div' => false, 'class' => 'span12', 'required' => false, 'placeholder' => "Nova Data", 'error' => false)); 
							?>
							
							<?php
							/* echo $this->element('datepicker', array(
									'field' => 'nova_data_entrega', 
									'label' => false, 
									'class' => 'span12',
									'empty' => true)) */?>
						</div>
					</div>
				</div>
				</div>				
			</fieldset>
		
		<?php if (!empty($this->data['Itensemprestimo'])) { ?>
			<table class="table table-bordered table-striped">
			<thead>
			<tr>
				<th>Código</th>
				<th>Equipamento</th>
				<th>Quantidade</th>
			</tr>
			</thead>
			<tbody>
		<?php
			foreach ($this->data['Itensemprestimo'] as $item): ?>
			<tr>
				<td><?php echo h($item['Equipamento']['id']); ?>&nbsp;</td>
				<td><?php echo h($item['Equipamento']['descricao']); ?>&nbsp;</td>
				<td><?php echo h($item['quantidade']); ?>&nbsp;</td>
			</tr>
		<?php endforeach; ?>
			</tbody>
			</table>
		<?php } ?>
		</div>
  <div class="modal-footer">
   	<?php echo $this->Js->submit('Confirmar', array(
		'url' => array('controller' => 'emprestimos', 'action' => 'renovacao'),
		'update' => '#window-modal',
    	'class' => "btn btn-primary",
   	    'before' => $this->Js->get('#ajax-indicator')->effect('fadeIn', array('buffer' => false)),
	    'complete' => $this->Js->get('#ajax-indicator')->effect('fadeOut', array('buffer' => false)),
		'buffer' => false,
		'div' => false
	));?>
	<a href="#" class="btn" data-dismiss="modal" >Cancelar</a>    
  </div>
<?php echo $this->Form->end();?>
<?php 
$webroot = ($this->webroot == '/')?$this->webroot.'webroot/':$this->webroot;
?>
<script type="text/javascript">
	$(document).ready(function () {
		$('#EmprestimoNovaDataEntrega').mask('99/99/9999').datepicker();
		$('#EmprestimoNovaDataEntregaCalendar').datepicker({
			showOn: 'button',
			buttonImage: '<?php echo "{$webroot}img/calendar-small.gif";?>',
			buttonImageOnly: true,
			changeMonth: true,
			changeYear: true,
			altField: '#EmprestimoNovaDataEntrega', altFormat: 'yy-mm-dd',
			onRender : $('#EmprestimoNovaDataEntrega').val($.datepicker.formatDate('yy-mm-dd', new Date()))
				
		});		
	});
</script>